/***************************************************************************
 *   Copyright (C) 2008 by Łukasz Spintzyk   *
 *   lukasz.spintzyk@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef DEVICE_OPTIONS_H
#define DEVICE_OPTIONS_H
#include <inttypes.h>
// 16 MHz
#define F_CPU 16000000UL  
#include <util/delay.h>

/* W tym pliku będą znajdować się definicje urządzeń zewnętrznych.
/ * Każde z nich będzie reprezentowane przez synonim, który będzie definiowany tutaj zależnie od
/ * tego jak jest wykonany projekt fizyczny.
/ * In this file evry constants which defines external devices/ports are kept.
/ * Every constant strongly depends on phisical design.
  */

#define PORT(x) XPORT(x)
#define XPORT(x) (PORT##x)

#define DDR(x) XDDR(x)
#define XDDR(x) (DDR##x)

#define PIN(x) XPIN(x)
#define XPIN(x) (PIN##x)

//definicja sygnałów kontrolnych
//Definition of constants which represents control bus of osciloscope.
#define CONTROL D
#define STA0 7
#define STA1 6
#define STB0 5
#define STB1 4
#define STAB_MASK ~((1<<STA1) | (1<<STA0) | (1<<STB1) | (1<<STB0))
//! \deprecated This constant is Deprecated because HighVoltage mode will be switched by a switch on board
#define CHA_HV 3
//! \deprecated This constant is Deprecated because HighVoltage mode will be switched by a switch on board
#define CHB_AC 2

//! Defines port where lcd control lines are plugged
#define LCD_CONTROL C
#define LCD_WR 7
#define LCD_RD 6
#define LCD_CD 5
#define LCD_CS 4
#define LCD_RST 3
#define ADC_CS 2

#define FONT_SIZE 6

//! 8-bit data port
#define DATA B
#define LCD_DATA DATA

//! Keyboard definition
#define KEYBOARD A
//! UP_KEY is connected to 3rd pin of KEYBOARD PORT
#define UP_KEY 3
#define DOWN_KEY 2
#define SELECT_KEY   4
#define SET_KEY 5
#define ANALOG_KEY 6
#define KEYBOARD_MASK (1<<UP_KEY | 1<<DOWN_KEY | 1<<SELECT_KEY | 1<<SET_KEY)

//! defines where is line which cuts off -VAA vltage for lcd, what is needed before LCD reset
#define _VEE_CUT_PORT A
#define _VEE_CUT_PIN 1

///! \todo zrobi? ma?y porz?dek z tymi sta?ymi
//! Definition of ADC port of Atmega32 microcontroller
#define ADCPORT_avr A
#define ANALOG_BUTTON_PIN 6
#define CH2_TB_PIN 7


#define ADCPORT_ext B
#define mmcu atmega32
#define HZ F_CPU
#define REFERENCE_VOLTAGE 5
#define ACTIVE 0xFF
#define INACTIVE 0x00

typedef unsigned char bool;
#define false 0
#define true 1
#define NULL 0

//struktura typu punkt
struct upoint8 {
        uint8_t x;
        uint8_t y;
};
typedef struct upoint8 upoint8_t;






//SET - po zaznaczeniu select i naci?ni?ciu set mo?na zmienia? warto?? za pomoc? przycisk�w/potencjometra
//dane si? zatwierdzaj? po ponownym naci?ni?ciu set, natomiast select przechodzi dalej i przywraca poprzedni? wartos?
//Klawisz UP_KEY na 1 bicie portu B


#endif
